package us.icitap.timsportal.business;

import java.io.Serializable;
import java.util.Arrays;

import us.icitap.timsportal.entity.Officer;

public class SimpleOfficer implements Serializable{
	
	/**
	 * 
	 */
	private static final long serialVersionUID = 4430348112072668492L;
	private String officerId;
	private String name;
	private String surname;
	private Integer orgStructureId;
	private String orgStructureName;
	private String[] orgList;
	
	public SimpleOfficer(){
		
	}
	
	public SimpleOfficer(Officer officer){
		this.officerId = officer.getOfficerId();
		this.name = officer.getForename();
		this.surname = officer.getSurname();
		if(officer.getOrgStructure()!=null){
			this.orgStructureId = officer.getOrgStructure().getId();
			this.orgStructureName = officer.getOrgStructure().getName();
		}
		this.orgList = officer.getParentStructureIds();
	}

	public String getOfficerId() {
		return officerId;
	}

	public void setOfficerId(String officerId) {
		this.officerId = officerId;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getSurname() {
		return surname;
	}

	public void setSurname(String surname) {
		this.surname = surname;
	}

	public Integer getOrgStructureId() {
		return orgStructureId;
	}

	public void setOrgStructureId(Integer orgStructureId) {
		this.orgStructureId = orgStructureId;
	}

	public String getOrgStructureName() {
		return orgStructureName;
	}

	public void setOrgStructureName(String orgStructureName) {
		this.orgStructureName = orgStructureName;
	}

	public String[] getOrgList() {
		return orgList;
	}

	public void setOrgList(String[] orgList) {
		this.orgList = orgList;
	}

	@Override
	public String toString() {
		return "SimpleOfficer [officerId=" + officerId + ", name=" + name
				+ ", surname=" + surname + ", orgStructureId=" + orgStructureId
				+ ", orgStructureName=" + orgStructureName + ", orgList="
				+ Arrays.toString(orgList) + "]";
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((name == null) ? 0 : name.hashCode());
		result = prime * result
				+ ((officerId == null) ? 0 : officerId.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (!(obj instanceof SimpleOfficer))
			return false;
		SimpleOfficer other = (SimpleOfficer) obj;
		if (name == null) {
			if (other.name != null)
				return false;
		} else if (!name.equals(other.name))
			return false;
		if (officerId == null) {
			if (other.officerId != null)
				return false;
		} else if (!officerId.equals(other.officerId))
			return false;
		return true;
	}

}
